package com.woniuxy.charin.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.charin.model.entity.TransactionOrder;
import com.woniuxy.charin.model.vo.TransactionOrderVo;
import com.woniuxy.charin.service.TransactionOrderService;
import com.woniuxy.charin.mapper.TransactionOrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;

/**
* @author Administrator
* @description 针对表【transaction_order】的数据库操作Service实现
* @createDate 2024-12-25 19:35:39
*/
@Service
public class TransactionOrderServiceImpl extends ServiceImpl<TransactionOrderMapper, TransactionOrder>
    implements TransactionOrderService{

    @Autowired
    private TransactionOrderMapper transactionOrderMapper;

    @Override
    public Page<TransactionOrderVo> getTransactionOrders(Map<String, Object> queryParams, int pageNum, int pageSize) {
        Page<TransactionOrderVo> page = new Page<>(pageNum, pageSize);
        return transactionOrderMapper.selectTransactionOrders(page, queryParams);
    }


    @Override
    public TransactionOrderVo getTransactionOrderById(Long id) {
        return transactionOrderMapper.selectTransactionOrderById(id);
    }



    @Override
    public void addTransactionOrder(TransactionOrder transactionOrder) {
        // 根据需求，可以设置默认值或检查必填字段
        if (transactionOrder.getCreateTime() == null) {
            transactionOrder.setCreateTime(new Date());
        }
        if (transactionOrder.getUpdateTime() == null) {
            transactionOrder.setUpdateTime(new Date());
        }
        this.save(transactionOrder); // 直接调用 MyBatis-Plus 的 `save` 方法
    }

}




